# 类里边的叫方法
class Person:
    # 初始化方法
    def __init__(self, name, age, height):
        self.name = name
        self.age = age
        self.height = height

    def run(self):
        print(self.name + "正在奔跑")

    def eat(self):
        print(self.name + "正在吃东西")


def test_usr():
    elephant = Person("大象", 18, 1.8)
    print(elephant.name, elephant.age, elephant.height)
    elephant.run()
    tiger = Person("老虎", 21, 1.75)
    print(tiger.name, tiger.age, tiger.height)
    tiger.eat()
    print(type(elephant))  # 类型：<class '__main__.Person'>
    print(type(Person))  # 类型：<class 'type'>
    print(dir(Person))  # 打印出 基本类所包含的类型
    print(dir(elephant))  # 会比基本类多出属性
    elephant.age = 35  # 可以改变类的属性
    print(elephant.name, elephant.age, elephant.height)


class Dog:
    def __init__(self, color, name):
        self.name = name
        self.color = color

    def action(self, duixiang):
        if duixiang == "外人":
            print(self.name + "汪汪叫")
        elif duixiang == "熟人":
            print(self.name + "摇尾巴")
        else:
            print(self.name + "睡觉")


if __name__ == '__main__':
    # test_usr()
    dog1 = Dog("黄颜色", "大黄")
    print(f"{dog1.color}的狗狗叫{dog1.name}")
    dog1.action("外人")
    dog1.action("熟人")
    dog1.action("小动物")
